<?php

/**
 * sfGuardUser form.
 *
 * @package    form
 * @subpackage sf_guard_user
 * @version    SVN: $Id: sfGuardUserForm.class.php 13001 2008-11-14 10:45:32Z noel $
 */
class sfGuardUserForm extends sfGuardUserAdminForm
{
  protected
    $pkName = null;

  public function configure()
  {
    parent::configure();

    unset(
      $this['last_login'],
      $this['created_at'],
      $this['salt'],
      $this['algorithm'],
      $this['is_active'],
      $this['is_super_admin'],
      $this['sf_guard_user_group_list'],
      $this['sf_guard_user_permission_list']
    );
    
  }

    /**
     * Returns the user info object. If it does
     * not exist return a new instance.
     *
     * @return UserInfo
     */
    protected function getUserInfo() {

        if (!$this->object->getSfGuardUserProfile()) {
            return new UserInfo();
        }

        return $this->object->getUserInfo();
    }

    /**
     * Updates the user info merged form.
     */
    protected function updateUserInfo() {

        if (!is_null($userInfo = $this->getUserInfo())) {

            $values = $this->getValues();
            if ($userInfo->isNew()) {
                $values['user_id'] = $this->object->getId();
            }

            $userInfo->fromArray($values, BasePeer::TYPE_FIELDNAME);

            $userInfo->save();
        }
    }
}
